import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { HomePageComponent } from '../components/homePage/homePage';
import { ForumComponent } from '../components/forum/forum';
import { ForumDetailComponent } from '../components/forumDetail/forumDetail';
import { EditorDeactivateGuardService } from '../service/EditorDeactivateGuardService';
import { ForumsResolveService} from '../service/ForumsResolveService';
import { NewsResolveService} from '../service/NewsResolveService';
import {ManageArticleComponent} from '../components/manageArticle/manageArticle';
import {AuthGuardService} from '../service/AuthGuardService';

const routes: Routes = [
    {
        path: 'home',
        component: HomePageComponent,
    },
    {
        path: 'forum',
        component: ForumComponent,
        canActivate: [AuthGuardService],
        canDeactivate: [ EditorDeactivateGuardService ],
        resolve: {
          results: ForumsResolveService,
          categorys: NewsResolveService
        }
    },
    {
        path: 'forumDetail/:id',
        canActivate: [AuthGuardService],
        component: ForumDetailComponent
    },
  {
    path: 'manageArticle',
    canActivate: [AuthGuardService],
    component: ManageArticleComponent
  }
];

@NgModule({
    imports: [ RouterModule.forChild(routes) ],
    exports: [ RouterModule ],
    providers: [
        EditorDeactivateGuardService,
        ForumsResolveService,
        NewsResolveService
    ]

})
export class HomeRoutingModule {}
